package com.godpaper.chessGameHall.managers
{
	import flash.display.DisplayObject;
	
	import mx.core.Application;
	import mx.core.IFlexDisplayObject;
	import mx.managers.CursorManager;
	import mx.managers.PopUpManager;
	
	
	public  class ProgressBarManager
	{
		private static var customProgressBarModule:IFlexDisplayObject;
		
		private static var count:int = 0;
		
		public static function showProgressBar():void
		{	
			count++;		
			if(count <= 1)
			{
				customProgressBarModule = 
				PopUpManager.createPopUp(Application.application as DisplayObject,CustomProgressBarModule,true,null);
				PopUpManager.centerPopUp(customProgressBarModule);
				CursorManager.setBusyCursor();
			}
		}
		public static function removeProgressBar():void
		{			
			if(customProgressBarModule)
			{
				if(count > 0) 
				{
					count--;
				}

				if(count <= 0)
				{
					PopUpManager.removePopUp(customProgressBarModule);
					customProgressBarModule = null;

					mx.managers.CursorManager.removeAllCursors();
				}
				
			}
			else
			{
				//Alert.show("progressBarIsNotReadyToRemove!","Fatal Error!");
			}	
			
		}
	}
}